package com.malie.myspringboot.designPattern;

import com.malie.myspringboot.designPattern.singleton.Singleton;
import com.malie.myspringboot.designPattern.singleton.Singleton2;
import com.malie.myspringboot.designPattern.singleton.Singleton3;
import com.malie.myspringboot.designPattern.singleton.Singleton4;
import org.junit.Test;

public class TestDemo {

    //饿汉式
    @Test
    public void test1() {
        Singleton instance = Singleton.getInstance();
        instance.show();
    }

    //懒汉式
    @Test
    public void test2() {
        Singleton2 instance = Singleton2.getInstance();
        instance.show();
    }

    //静态内部类
    @Test
    public void test3() {
        Singleton3 instance = Singleton3.getInstance();
        instance.show();
    }

    //枚举
    @Test
    public void test4() {
        Singleton4.INSTANCE.show();
    }
}
